<template>
  <el-card>
    <template #header>
      <i class="el-icon-back" @click="$router.go(-1)"></i>
      订单的编辑
    </template>
    <el-form ref="form" :model="form" label-width="80px" size="mini">
      <el-form-item label="订单号">
        <el-input v-model="form.orderNo"></el-input>
      </el-form-item>
      <el-form-item label="下单时间">
        <template></template>
        <el-input v-model="form.orderTime"></el-input>
      </el-form-item>
      <el-form-item label="电话">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item label="收货人">
        <el-input v-model="form.consignee"></el-input>
      </el-form-item>
      <el-form-item label="送货地址">
        <el-input v-model="form.deliverAddress"></el-input>
      </el-form-item>
      <el-form-item label="送达时间">
        <el-input v-model="form.deliveryTime"></el-input>
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="form.remarks"></el-input>
      </el-form-item>
      <el-form-item label="订单金额">
        <el-input v-model="form.orderAmount"></el-input>
      </el-form-item>
      <el-form-item label="订单状态">
        <el-input v-model="form.orderState"></el-input>
      </el-form-item>
      <el-button type="primary" @click="yesBtn" size="mini">确 定</el-button>
    </el-form>
  </el-card>
</template>

<script>
import moment from 'moment'
import { editorder } from '../../api/list.js'
export default {
  data() {
    return {
      form: {
        id: '',
        orderNo: '',
        orderTime: '',
        phone: '',
        consignee: '',
        deliverAddress: '',
        deliveryTime: '',
        remarks: '',
        orderAmount: '',
        orderState: ''
      }
    }
  },
  created() {
    this.$route.query.data.orderTime = moment(
      this.$route.query.data.orderTime
    ).format('YYYY-MM-DD HH:mm:ss')
    this.$route.query.data.deliveryTime = moment(
      this.$route.query.data.deliveryTime
    ).format('YYYY-MM-DD HH:mm:ss')
    this.form = this.$route.query.data
  },
  methods: {
    async yesBtn() {
      const data = await editorder(this.form)
      if (data.code === 0) {
        this.$router.push('/order/list')
      }
    }
  }
}
</script>

<style lang="less" scoped>
.el-input {
  width: 200px;
}
</style>
